package com.groupbuying.customer.controller;

import com.groupbuying.customer.context.FilterContextHandler;
import com.groupbuying.customer.service.CustomerCurrencyService;
import com.groupbuying.customer.utils.PageUtils;
import com.groupbuying.customer.utils.apiresult.ApiResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;

/**
 * @Author WANGNING
 * @Description 用户积分收支明细
 * @Date 2019/8/28 10:05
 **/
@RestController
@RequestMapping("/currency")
public class CustomerCurrencyController {
    private static final Logger logger = LoggerFactory.getLogger(CustomerCurrencyController.class);

    @Autowired
    private CustomerCurrencyService customerCurrencyService;

    @GetMapping("/details")
    public PageUtils details(@RequestParam Map<String, Object> params) {
        logger.error("CustomerCurrencyController.details()-----获取到的前台传递的参数信息："+params.toString());
        //查询列表数据
        String consumerId = FilterContextHandler.getUserID();
        logger.error("CustomerCurrencyController.details()-----；获取到的consumerId："+consumerId);
        params.put("consumerId",consumerId);
        PageUtils details = customerCurrencyService.customerCurrency(params);
        return details;
    }
    //查询列表详情
    @GetMapping("/getCurrencyDetails")
    public PageUtils getCurrencyDetails(@RequestBody Map<String,Object> map){
        return customerCurrencyService.getCurrencyDetails(map);
    }
    //查询积分
    @GetMapping("/getAllCurrency")
    public  Map getAllCurrency(@RequestBody Map<String,Object> map){
        return customerCurrencyService.getAllCurrency(map);
    }
    //查询积分详情
    @GetMapping("/getCurrencyLogByCustomerId")
    public  PageUtils getCurrencyLogByCustomerId(@RequestBody Map<String,Object> map){
        return customerCurrencyService.getCurrencyLogByCustomerId(map);
    }
    //按月份统计积分
    @GetMapping("/getMouthCurrency")
    public ApiResult getMouthCurrency(@RequestBody Map<String,String> map){
        List<Map<String, Object>> mouthCurrency = customerCurrencyService.getMouthCurrency(map);
       return  ApiResult.success(mouthCurrency);
       /* Map<String,Object> param = new HashMap<>();
        param.put("mouthCurrency",mouthCurrency);
        return param;*/
    }
}
